#!/usr/bin/make -f
#include /usr/share/cdbs/1/rules/debhelper.mk
#DEB_PYTHON_SYSTEM=pycentral
#include /usr/share/cdbs/1/class/python-distutils.mk
#DEB_PYTHON_SETUP_CMD_conceal=conceal/setup.py

PYTHON	:= /usr/bin/python
PYVER   := $(shell $(PYTHON) -c 'import sys; print sys.version[:3]')

build: build-stamp

build-stamp:
	dh_testdir
	cd conceal && python setup.py build && cd -
	cd conceal-gtk && python setup.py build && cd -
	cd conceal-kde && python setup.py build && cd -
	cd nautilus-conceal && python setup.py build && cd -
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	-find . -name '.svn' | xargs rm -Rf
	-find . -name 'build' | xargs rm -Rf
	-find . -name 'build-stamp' | xargs rm -Rf
	-find . -name '*.py[co]' | xargs rm -f
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k 
	dh_installdirs
	
	# Build using distutils
	cd conceal && python setup.py install \
		--root=$(CURDIR)/debian/conceal && cd -
	cd conceal-gtk && python setup.py install \
		--root=$(CURDIR)/debian/conceal-gtk && cd -
	cd conceal-kde && python setup.py install \
		--root=$(CURDIR)/debian/conceal-kde && cd -
	cd nautilus-conceal && python setup.py install \
		--root=$(CURDIR)/debian/nautilus-conceal && cd -
	
	# binary-or-shlib-defines-rpath
	chrpath -d $(CURDIR)/debian/conceal-kde/usr/lib/kde3/kcm_*.so.*
	
	# script-not-executable
	chmod a+x $(CURDIR)/debian/conceal/usr/lib/python2.5/site-packages/conceal.py
	
	# Fix link
	rm $(CURDIR)/debian/conceal-kde/usr/bin/conceal-kde
	cd $(CURDIR)/debian/conceal-kde/usr/bin/ && ln -s ../share/apps/conceal-kde/conceal-kde.py conceal-kde && cd -
	
# Build architecture-independent files here.
binary-indep: build install
	mkdir -p $(CURDIR)/debian/conceal/usr/share/doc/conceal
	mkdir -p $(CURDIR)/debian/conceal-gtk/usr/share/doc/conceal-gtk
	mkdir -p $(CURDIR)/debian/nautilus-conceal/usr/share/doc/nautilus-conceal
	mkdir -p $(CURDIR)/debian/conceal-kde/usr/share/doc/conceal-kde
#	gzip -c -9 $(CURDIR)/debian/changelog > $(CURDIR)/debian/conceal/usr/share/doc/conceal/changelog.Debian.gz
#	cp $(CURDIR)/debian/conceal/usr/share/doc/conceal/changelog.Debian.gz $(CURDIR)/debian/conceal-gtk/usr/share/doc/conceal-gtk
#	cp $(CURDIR)/debian/conceal/usr/share/doc/conceal/changelog.Debian.gz $(CURDIR)/debian/nautilus-conceal/usr/share/doc/nautilus-conceal
/bin/bash: q : commande introuvable
	dh_testdir
	dh_testroot
	dh_installdocs README
#	dh_installexamples examples/*
	dh_installman
	: # Replace all '#!' calls to python with $(PYTHON)
	: # and make them executable
#	for i in `find debian -mindepth 3 -type f`; do \
#	  sed '1s,#!.*python[^ ]*\(.*\),#! $(PYTHON)\1,' \
#	        $$i > $$i.temp; \
#	  if cmp --quiet $$i $$i.temp; then \
#	    rm -f $$i.temp; \
#	  else \
#	    mv -f $$i.temp $$i; \
#	    chmod 755 $$i; \
#	    echo "fixed interpreter: $$i"; \
#	  fi; \
#	done
	dh_pycentral
	dh_python
	dh_compress -X.py
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-dependent files here.
binary-arch: build install
# We have nothing to do by default.

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
